//
// MethodReturnsStructTest.m
// Copyright 2010 Mark Buer
//
// This file is part of zc-aspect.
//
// zc-aspect is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// zc-aspect is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with zc-aspect.  If not, see <http://www.gnu.org/licenses/>.
//

#import "MethodReturnsStructTest.h"


@interface MethodReturnsStructTest ()

@property (assign, nonatomic) BOOL didIntercept;

@end



@implementation MethodReturnsStructTest

@synthesize didIntercept;


#pragma mark -
#pragma mark Test Initialisation


- (void)setUp {
	[ZCInterceptionManager interceptMethod:class_getInstanceMethod(self.class, @selector(returnsStruct)) withInterceptor:self];
	didIntercept = NO;
}


- (void)tearDown {
}


#pragma mark -
#pragma mark Interceptor(Delegate) TODO Fix my name!


- (void)interceptInvocation:(Invocation *)invocation {
	didIntercept = YES;
	invocation_invoke(invocation);
}


#pragma mark -
#pragma mark Test-subject Method


- (TestStruct)returnsStruct {
	TestStruct result;
	result.someInt = 123456;
	result.someDouble = 123.456;
	return result;
}


#pragma mark -
#pragma mark Test Methods


- (void)testInterceptedMethodReturnsStruct {
	TestStruct result = [self returnsStruct];
	STAssertTrue(result.someInt == 123456, nil);
	STAssertTrue(result.someDouble == 123.456, nil);
    STAssertTrue(didIntercept, nil);
}


@end
